package ren.nearby.home;

import android.app.Activity;
import android.view.View;
import android.widget.Button;

import com.orhanobut.logger.Logger;

import javax.inject.Inject;

import ren.nearby.home.mvp.RequestAPIAction;
import ren.nearby.home.mvp.RequestAPIContract;
import ren.nearby.http.base.BaseActivity;

/**
 * Created by Administrator on 2019/1/21 0021.
 */

public class RequestAPI extends BaseActivity implements RequestAPIContract.View {

    @Inject
    RequestAPIContract.Action action;
    Button home_btn_request_api;

    @Override
    public boolean isStateLayout() {
        return true;
    }

    @Override
    public Activity getContext() {
        return this;
    }

    @Override
    public void setPresenter(RequestAPIAction presenter) {

    }

    @Override
    public void onIntent() {
        super.onIntent();
        action.takeView(this);
    }

    @Override
    public int getContentView() {
        return R.layout.home_request_api;
    }

    @Override
    public void loadError() {
        Logger.e("loaderror");
        pageStateLayout.onError();
    }

    @Override
    public void loadSucces() {
        pageStateLayout.onSucceed();
    }

    @Override
    public void initView() {
        super.initView();
        pageStateLayout.onLoading();
        home_btn_request_api = findViewById(R.id.home_btn_request_api);
        home_btn_request_api.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pageStateLayout.onLoading();
                action.test();
            }
        });
        action.test();
    }
}
